/*!
\copyright  Copyright (c) 2025 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\ingroup    user_eq
\brief      Build SET_PARAM message from provided gains.

*/

#include "user_eq_set_params.h"

#include "user_eq_params_conversion.h"

#define NUMBER_OF_CORE_BAND_PARAMS 4
#define NUMBER_OF_PARAMS_PER_BAND 4

typedef enum
{
    peq_filter_param_filter_type = 0,
    peq_filter_param_cut_off_frequency,
    peq_filter_param_gain,
    peq_filter_param_q
} eq_param_t;

static uint16 kymera_GetParamId(const uint16 bandm, eq_param_t peq_filter_param)
{
    return (uint16)(NUMBER_OF_CORE_BAND_PARAMS + (uint16)(NUMBER_OF_PARAMS_PER_BAND * bandm) + peq_filter_param);
}

set_params_data_t *UserEq_SetParamsCreateWithGains(uint8 start_band, uint8 end_band, int16 *gains)
{
    uint8 i;
    uint8 gain_index;
    set_params_data_t* set_params_data = OperatorsCreateSetParamsData((end_band - start_band) + 1);

    gain_index = 0;
    for (i = start_band; i <= end_band; i++)
    {
        set_params_data->standard_params[gain_index].id = kymera_GetParamId(i, peq_filter_param_gain);
        set_params_data->standard_params[gain_index].value = UserEq_ParamsConversionGainToQFormat(gains[i]);
        ++gain_index;
    }

    return set_params_data;
}